<template>
  <div class="wrapper">
    <el-card class="form-wrapper" shadow="never">
      <el-form class="form" :model="formData" inline>
        <el-form-item label="姓名">
          <el-input v-model="formData.name" clearable @keyup.enter="resetPage" />
        </el-form-item>
        <el-form-item label="电话">
          <el-input v-model="formData.phone" clearable @keyup.enter="resetPage" />
        </el-form-item>
        <el-form-item label="状态">
          <el-input v-model="formData.status" clearable @keyup.enter="resetPage" />
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="resetPage">查询</el-button>
          <el-button @click="resetParams">重置</el-button>
        </el-form-item>
      </el-form>
    </el-card>
    <el-card v-loading="pager.loading" class="mt-4 !border-none relative" shadow="never">
      <div class="absolute right-4 top-2">
        <popover-input @confirm="handleSetOperatorDept($event)">
                <el-button type="primary" link v-perms="['user:edit']">
                    <icon name="el-icon-Tools" />
                </el-button>
       </popover-input>
      </div>
      <div class="mt-4">
        <el-table :data="pager.lists" size="large">
          <el-table-column label="序号" prop="id" min-width="60" />
          <el-table-column label="姓名" prop="nickname" min-width="100" />
          <el-table-column label="部门" prop="dept" min-width="100" />
          <el-table-column label="岗位" prop="post" min-width="100" />
          <el-table-column label="客户" prop="client" min-width="100" />
          <!-- <el-table-column label="状态" min-width="100">
            <template #default="{ row }">
              <el-switch v-if="row.id != 1" :model-value="row.status" :active-value="1" :inactive-value="0"
                active-text="在职" inactive-text="离职" @change="changeStatus($event, row.id)" />
            </template>
          </el-table-column> -->
          <el-table-column label="操作" width="120" fixed="right">
            <template #default="{ row }">
              <!-- <el-button type="primary" link @click="handleEdit(row)">
                分配
              </el-button> -->
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="flex mt-4 justify-end">
        <pagination v-model="pager" @change="getLists" />
      </div>
    </el-card>

  </div>
</template>

<script lang="ts" setup>
// import { deleteUserApi, getUserListAPI, changeUserStatusApi } from '@/api/permission/user'
import { listsApi, setConfigApi } from "@/api/operator"
import { useDictOptions } from '@/hooks/useDictOptions'
import { usePaging } from '@/hooks/usePaging'
import feedback from '@/utils/feedback'
import { nextTick, onMounted, reactive, ref, shallowRef } from 'vue'

import pagination from "@/components/pagination/index.vue"
// 表单数据
const formData = reactive({
  name: '',
  phone: '',
  status: '',
  entryTime: "",
  resignationTime: ""
})
const { pager, getLists, resetParams, resetPage } = usePaging({
  fetchFun: listsApi,
  params: formData
})

async function handleSetOperatorDept(e: any) {
  await setConfigApi({
    deptId: e
  })
}


onMounted(() => {
  getLists()
})
</script>
<style lang="scss" scoped>
.text_hidden {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  overflow: hidden;
}

.wrapper {
  .form-wrapper {

    padding-bottom: 0px;

    .form {
      // margin-bottom: 14px;
    }
  }
}
</style>
